<?php
declare(strict_types=1);
namespace Field;

class AuthUserGridRuleConst
{
    public const pk='';
    public const index=['UserID','GridName'];
	public const fields=['UserID','GridName','GridKey','Config','CreateAt','UpdateAt'];
	public const comment=['UserID'=>'会员ID','GridName'=>'表格','GridKey'=>'表格','Config'=>'','CreateAt'=>'','UpdateAt'=>''];
	/*
    * @Field UserID
    * @Type int(11)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 会员ID
    */
    public const UserID = 'UserID';
    /*
    * @Field GridName
    * @Type char(32)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 表格
    */
    public const GridName = 'GridName';
    /*
    * @Field GridKey
    * @Type char(32)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 表格
    */
    public const GridKey = 'GridKey';
    /*
    * @Field Config
    * @Type text
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Config = 'Config';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UpdateAt = 'UpdateAt';
}

class AuthUserGridRuleColumns
{
public  int $UserID;
   public  string $GridName;
   public  string $GridKey;
   public  ?string $Config='';
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
	public function toArray():array
	{
		return [
'UserID'=>$this->UserID,
    'GridName'=>$this->GridName,
    'GridKey'=>$this->GridKey,
    'Config'=>$this->Config,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,        ];
	}
}

class AuthUserGridRuleRow
{
	public AuthUserGridRuleColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'UserID' => $this->data->UserID,
        'GridName' => $this->data->GridName,
        'GridKey' => $this->data->GridKey,
        'Config' => $this->data->Config,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new AuthUserGridRuleColumns();
        isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['GridName']) && $this->data->GridName = (string)$data['GridName'];
           isset($data['GridKey']) && $this->data->GridKey = (string)$data['GridKey'];
           isset($data['Config']) && $this->data->Config = (string)$data['Config'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
    }
}
?>